//! File and filesystem-related syscalls

const FD_STDOUT: usize = 1;

/// write buf of length `len`  to a file with `fd`
pub fn sys_write(fd: usize, buf: *const u8, len: usize) -> isize {
    match fd {
        FD_STDOUT => {
            let silce = unsafe { core::slice::from_raw_parts(buf, len) };
            let str = core::str::from_utf8(silce).expect("sys_write STDOUT is not valid utf-8!");
            print!("{}", str);
            len as isize
        }
        _ => panic!("Unsupported fd in sys_write!"),
    }
}
